<?php /*a:2:{s:61:"/www/wwwroot/cloud_boss/application/admin/view/menu/form.html";i:1573743224;s:64:"/www/wwwroot/cloud_boss/application/admin/view/public/basic.html";i:1573743224;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo htmlentities((isset($title) && ($title !== '')?$title:'重庆优合一众')); ?></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/plugs/layui/css/layui.css" media="all"/>
    <!--<link rel="stylesheet" href="/static/layuicms/css/index.css" media="all" />-->
    
</head>
<body class="<?php echo htmlentities((isset($body) && ($body !== '')?$body:'childrenBody')); ?>">

<form class="layui-form" style="width:80%;">
    <br>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">上级菜单</label>
        <div class="layui-input-block">
            <select name="pid" class="pid" lay-filter="pid">
                <?php foreach($up_menu as $vo): if($vo['id'] == (isset($menu['pid']) && ($menu['pid'] !== '')?$menu['pid']:0)): ?>
                <option selected value="<?php echo htmlentities((isset($vo['id']) && ($vo['id'] !== '')?$vo['id']:'')); ?>"><?php echo (isset($vo['title']) && ($vo['title'] !== '')?$vo['title']:''); ?></option>
                <?php else: ?>
                <option value="<?php echo htmlentities((isset($vo['id']) && ($vo['id'] !== '')?$vo['id']:'')); ?>"><?php echo (isset($vo['title']) && ($vo['title'] !== '')?$vo['title']:''); ?></option>
                <?php endif; ?>
                <?php endforeach; ?>
            </select>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">菜单名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" class="layui-input title" lay-verify="title" lay-verify="required" value="<?php echo htmlentities((isset($menu['title']) && ($menu['title'] !== '')?$menu['title']:'')); ?>" placeholder="请输入菜单名称">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">菜单链接</label>
        <div class="layui-input-block">
            <input type="text" name="href" class="layui-input href" lay-verify="href" value="<?php echo htmlentities((isset($menu['href']) && ($menu['href'] !== '')?$menu['href']:'#')); ?>" placeholder="请输入菜单链接">
        </div>
    </div>

    <div class="layui-form-item layui-row">
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">图标编码</label>
            <div class="layui-input-block">
                <input type="text" name="icon" class="layui-input icon" lay-verify="icon" value="<?php echo htmlentities((isset($menu['icon']) && ($menu['icon'] !== '')?$menu['icon']:'')); ?>" placeholder="请输入图标编码">
            </div>
        </div>

        <div class="magb15 layui-col-md4 layui-col-xs12">
            <?php if(!empty($menu['icon'])): ?>
            <label class="layui-form-label">图标样式</label>
            <span class='layui-btn layui-btn-primary' style='padding:0 12px;min-width:45px'>
                <i id='icon-preview' class="layui-icon" data-icon="<?php echo (isset($menu['icon']) && ($menu['icon'] !== '')?$menu['icon']:''); ?>"><?php echo (isset($menu['icon']) && ($menu['icon'] !== '')?$menu['icon']:''); ?></i>
             </span>
            <?php endif; ?>
            <button data-icon='icon' type='button' class='layui-btn layui-btn-primary select_icon'>选择图标</button>
        </div>


        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">菜单排序</label>
            <div class="layui-input-block">
                <input type="text" name="sort" class="layui-input sort" lay-verify="sort" value="<?php echo htmlentities((isset($menu['sort']) && ($menu['sort'] !== '')?$menu['sort']:'0')); ?>" placeholder="请输入排序">
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入备注信息" class="layui-textarea remark"><?php echo htmlentities((isset($menu['remark']) && ($menu['remark'] !== '')?$menu['remark']:'')); ?></textarea>
        </div>
    </div>

    <?php if(!empty($menu)): ?>
    <input type="hidden" class="id" name="id" value="<?php echo htmlentities((isset($menu['id']) && ($menu['id'] !== '')?$menu['id']:'')); ?>">
    <?php endif; ?>

    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="addMenu">立即添加</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
        </div>
    </div>
</form>

<script type="text/javascript" src="/static/plugs/jquery/jquery-2.2.4.min.js"></script>
<script type="text/javascript" src="/static/plugs/layui/layui.js"></script>
<script type="text/javascript" src="/static/admin.js"></script>
<script type="text/javascript" src="/static/js/admin/api.js"></script>

<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery;

        form.on("submit(addMenu)", function (data) {
            //弹出loading
            var index = top.layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
            // 实际使用时的提交信息
            $.post('<?php if(empty($menu)): ?><?php echo url("$thisClass/add"); else: ?><?php echo url("$thisClass/edit"); ?><?php endif; ?>', {
                id: $(".id").val(),
                pid: data.field.pid,  //登录名
                title: $(".title").val(),  //邮箱
                href: $(".href").val(),  //性别
                icon: $(".icon").val(),  //性别
                sort: $(".sort").val(),  //性别
                status: data.field.status,    //用户状态
                remark: $(".remark").val(),    //用户简介
            }, function (res) {
                console.log(res);
                if (res.code == 0) {
                    layer.msg(res.msg, {icon: 1}, function () {
                        layer.closeAll("iframe");
                        parent.location.reload();
                    });
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            })
            return false;
        })

        //格式化时间
        function filterTime(val) {
            if (val < 10) {
                return "0" + val;
            } else {
                return val;
            }
        }


        $(".select_icon").click(function () {
            var selectIcon = layui.layer.open({
                title: "选择图标",
                type: 2,
                area: ['800px', '500px'],
                content: '<?php echo url("$thisModule/icon/index"); ?>',
                success: function (layero, selectIcon) {
                    var body = layui.layer.getChildFrame('body', selectIcon);
                }
            })
            // layui.layer.full(index);
            //改变窗口大小时，重置弹窗的宽高，防止超出可视区域（如F12调出debug的操作）
            $(window).on("resize", function () {
                layui.layer.full(index);
            })
        })

    })
</script>

</body>
</html>